package controller

import (
	"github.com/gofiber/fiber"
	"gowork/mungBean/model"
	"strconv"
)

type MungBeanController struct {
	TelephoneInformation *model.TelephoneInformation
}

func (mbc *MungBeanController)QueryPhoneInfo(c *fiber.Ctx){

	mbc.TelephoneInformation = new(model.TelephoneInformation)

	customerIdStr := c.FormValue("customerId")
	customerId, err := strconv.ParseInt(customerIdStr,10, 64)
	if err != nil{
		c.JSON(fiber.Map{
			"code": 500,
			"data": nil,
			"message": err.Error(),
		})
		return
	}

	res , err := mbc.TelephoneInformation.QueryPhoneInfo(customerId)
	if err != nil{
		c.JSON(fiber.Map{
			"code": 500,
			"data": nil,
			"message": err.Error(),
		})
		return
	}

	c.JSON(fiber.Map{
		"code": "200",
		"data": res,
		"message": "成功",
	})
	return
}
